import Vue from 'vue';
import { openKeyBoard } from '../utils/keyboard';
Vue.directive('keyBoard', {
  bind: function (el, binding, vnode) {
    if(!process.env.IS_ELECTRON) return;
    window._focus=true;
    window._keyboard=false;
    el.onfocus=(e) =>{
      if(!window._focus||window._keyboard) return;
      window._focus=false;
      window._keyboard=true;
      openKeyBoard(() =>{
        e.target.blur();
        window._focus=true;
        window._keyboard=false;
      });
    }
  },
  unbind:function(el, binding, vnode,oldVode){
    if(process.env.IS_ELECTRON) return;
    el.onfocus=() =>{};
  }
});